package cn.tedu.charging.order.dao.repository.impl;

import cn.tedu.charging.order.dao.mapper.BillFailMapper;
import cn.tedu.charging.order.dao.mapper.BillSuccessMapper;
import cn.tedu.charging.order.dao.repository.BillRepository;
import cn.tedu.charging.order.pojo.po.ChargingBillFailPO;
import cn.tedu.charging.order.pojo.po.ChargingBillSuccessPO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class BillRepositoryImpl implements BillRepository {
    @Autowired
    private BillSuccessMapper billSuccessMapper;
    @Autowired
    private BillFailMapper billFailMapper;
    @Override
    public void saveFailBill(ChargingBillFailPO fail) {
        billFailMapper.insert(fail);
    }

    @Override
    public void saveSuccessBill(ChargingBillSuccessPO success) {
        billSuccessMapper.insert(success);
    }

    @Override
    public long countSuccess(String orderNo) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("bill_id",orderNo);
        return billSuccessMapper.selectCount(queryWrapper);
    }

    @Override
    public long countFail(String orderNo) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("bill_id",orderNo);
        return billFailMapper.selectCount(queryWrapper);
    }
}
